package com.oocl.handlebatchdata.dataprocess;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Set;

import com.oocl.handlebatchdata.customer.Customer;
import com.oocl.handlebatchdata.isgooddata.IsGoodData;


public class DataProcessImpl implements DataProcess<Customer>{

	Set<Customer> cs1;
	Set<Customer> cs2;
	
	public DataProcessImpl(Set<Customer> cs1,Set<Customer> cs2)
	{
		this.cs1=cs1;
		this.cs2=cs2;
	}
	
	public void setdata()  {
		String[] sp;
		Customer customer;
		try {
			Scanner sc = new Scanner(new FileInputStream("data.txt"));
			String data;
			while(sc.hasNext()){
				data=sc.nextLine();
//				System.out.println(data);
				sp=data.split("\\s+");
//				System.out.println(sp[0]+sp[1]+sp[2]+sp[3]+sp[4]);
//				System.out.println("yes111");
				if(IsGoodData.isGoodData(sp)){
//					System.out.println("yes222");
					customer=new Customer(sp[0], sp[1], sp[2], sp[3], sp[4]);
					cs1.add(customer);
					cs2.add(customer);
//					for(Customer c:cs2)System.out.println(cs2);
				}	
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}



}
